From: Ximin Luo Date: Thu, 15 Feb 2018 15:01:36 +0000 (+0100) Subject: Add some tests to check that dev-dependencies are not resolved X-Git-Tag: archive/raspbian/0.35.0-2+rpi1~3^2^2^2^2^2^2^2~22^2~2^2~56^2~4 X-Git-Url: https://dgit.raspbian.org/%22http://www.example.com/cgi/success//%22http:/www.example.com/cgi/success/?a=commitdiff_plain;h=da41b4e0391f23d282981e8d0f2c700b3fe4972d;p=cargo.git Add some tests to check that dev-dependencies are not resolved --- diff --git a/tests/build.rs b/tests/build.rs index 14237e4c9..ee09ff0be 100644 --- a/tests/build.rs +++ b/tests/build.rs @@ -4188,3 +4188,24 @@ fn no_linkable_target() { [WARNING] The package `the_lib` provides no linkable [..] \ while compiling `foo`. [..] in `the_lib`'s Cargo.toml. [..]")); } + +#[test] +fn avoid_dev_deps() { + Package::new("foo", "1.0.0").publish(); + let p = project("foo") + .file("Cargo.toml", r#" + [package] + name = "bar" + version = "0.1.0" + authors = [] + + [dev-dependencies] + baz = "1.0.0" + "#) + .file("src/main.rs", "fn main() {}") + .build(); + + assert_that(p.cargo("build"), execs().with_status(101)); + assert_that(p.cargo("build").masquerade_as_nightly_cargo() + .arg("-Zavoid-dev-deps"), execs().with_status(0)); +} diff --git a/tests/install.rs b/tests/install.rs index 1ae6806c4..14b64c6c6 100644 --- a/tests/install.rs +++ b/tests/install.rs @@ -6,6 +6,7 @@ use std::fs::{self, File, OpenOptions}; use std::io::prelude::*; use cargo::util::ProcessBuilder; +use cargotest::ChannelChanger; use cargotest::install::{cargo_home, has_installed_exe}; use cargotest::support::git; use cargotest::support::paths; @@ -907,6 +908,56 @@ fn use_path_workspace() { assert!(lock == lock2, "different lockfiles"); } +#[test] +fn dev_dependencies_no_check() { + Package::new("foo", "1.0.0").publish(); + let p = project("foo") + .file("Cargo.toml", r#" + [package] + name = "bar" + version = "0.1.0" + authors = [] + + [dev-dependencies] + baz = "1.0.0" + "#) + .file("src/main.rs", "fn main() {}") + .build(); + + assert_that(p.cargo("build"), execs().with_status(101)); + assert_that(p.cargo("install"), execs().with_status(0)); +} + +#[test] +fn dev_dependencies_lock_file_untouched() { + Package::new("foo", "1.0.0").publish(); + let p = project("foo") + .file("Cargo.toml", r#" + [package] + name = "foo" + version = "0.1.0" + authors = [] + + [dev-dependencies] + bar = { path = "a" } + "#) + .file("src/main.rs", "fn main() {}") + .file("a/Cargo.toml", r#" + [package] + name = "bar" + version = "0.1.0" + authors = [] + "#) + .file("a/src/lib.rs", "") + .build(); + + assert_that(p.cargo("build"), execs().with_status(0)); + let lock = p.read_lockfile(); + assert_that(p.cargo("install"), execs().with_status(0)); + let lock2 = p.read_lockfile(); + assert!(lock == lock2, "different lockfiles"); +} + #[test] fn vers_precise() { pkg("foo", "0.1.1");